'use client';

import { useEffect } from 'react';
import { Sidebar } from '@/components/Sidebar';
import { ChatArea } from '@/components/ChatArea';
import { DocumentPanel } from '@/components/DocumentPanel';
import { useAppStore, useSidebarOpen } from '@/store';
import { cn } from '@/lib/utils';

export default function HomePage() {
  const sidebarOpen = useSidebarOpen();
  const { setUser } = useAppStore();

  useEffect(() => {
    // 初始化用户（这里可以集成真实的认证系统）
    setUser({
      id: 'demo-user',
      name: 'Demo User',
      email: 'demo@example.com',
      avatar: null,
      created_at: new Date().toISOString(),
      updated_at: new Date().toISOString(),
    });
  }, [setUser]);

  return (
    <div className='flex h-screen bg-background'>
      {/* 侧边栏 */}
      <div
        className={cn(
          'transition-all duration-300 ease-in-out',
          sidebarOpen ? 'w-80' : 'w-0'
        )}
      >
        <Sidebar />
      </div>

      {/* 主内容区域 */}
      <div className='flex-1 flex'>
        {/* 聊天区域 */}
        <div className='flex-1 flex flex-col'>
          <ChatArea />
        </div>

        {/* 文档面板 */}
        <div className='w-96 border-l border-border'>
          <DocumentPanel />
        </div>
      </div>
    </div>
  );
}
